#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import re
from datetime import datetime
from typing import Dict, List, Set, Optional, Tuple
from enum import Enum
import logging
from tree_sitter import Tree, Node
from typing_extensions import Any

# 导入数据结构
from parser.refactor.data_structures import (
    ClassInfo, ParserContext, DependencyContext, DependencyType,
    MethodInfo, FieldInfo, AnnotationInfo, GraphNodeInfo, GraphEdgeInfo,
    MetadataInfo, RelationshipInfo, RelationshipCollection,
    ClassType, Visibility, FileInfo, ParameterInfo, CommentInfo
)
from parser.refactor.java_metadata_extractor.java_metadata_extractor import JavaMetadataExtractor
from parser.refactor.java_node_type import (JavaNodeType)

logger = logging.getLogger(__name__)


class JavaFileExtractor(JavaMetadataExtractor):
    """Java文件元数据提取器"""

    def extract_file_info(self, file_path: str, package_name: str, code_bytes: bytes) -> FileInfo:
        """
        提取文件信息

        Args:
            file_path: 文件路径
            package_name: 包名
            code_bytes: 文件内容

        Returns:
            文件信息

        """

        # 提取文件信息
        return FileInfo (
            file_path = file_path,
            file_name = os.path.basename(file_path),
            package_name = package_name,
            extension = os.path.splitext(file_path)[1],
            modification_time = datetime.fromtimestamp(os.path.getmtime(file_path)).isoformat(),
            size = len(code_bytes)
        )
